﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Collections;
using MyQQListView.Enum;

namespace MyQQListView
{
    [Serializable]
    public class Group
    {
        private string title = string.Empty;
        /// <summary>
        /// 分组标题
        /// </summary>
        public string Title
        {
            get
            {
                return title;
            }
            set
            {
                title = value;
            }
        }

        private int id = 0;
        /// <summary>
        /// 分组编号
        /// </summary>
        public int Id
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
            }
        }

        private int onlineFriendCount = 0;
        /// <summary>
        /// 在线用户
        /// </summary>
        public int OnlineFriendCount
        {
            get
            {
                return onlineFriendCount;
            }
            set
            {
                onlineFriendCount = value;
            }
        }

        private int friendCount = 0;
        /// <summary>
        /// 好友数量
        /// </summary>
        public int FriendCount
        {
            get
            {
                return friendCount;
            }
            //set
            //{
            //    friendCount = value;
            //}
        }

        private IList<Friend> friends;
        /// <summary>
        /// 分组中的所有好友
        /// </summary>
        public IList<Friend> Friends
        {
            get
            {
                if (friends == null) return new List<Friend>();
                else return friends;
            }
            set
            {
                friends = value;
                if (value != null)
                    friendCount = friends.Count;
            }
        }

        private UserOrder userOrder = UserOrder.NickName;
        /// <summary>
        /// 排序方式
        /// </summary>
        public UserOrder UserOrder
        {
            get
            {
                return userOrder;
            }
            set
            {
                userOrder = value;
                switch (value)
                {
                    case UserOrder.Uin:
                        if (friends != null && friends.Count > 1)
                            friends = friends.OrderBy(f => f.Uin).ToList();
                        break;
                    case UserOrder.NickName:
                        if (friends != null && friends.Count > 1)
                            friends = friends.OrderBy(f => f.NikeName).ToList();
                        break;
                    case UserOrder.LastChat:
                        if (friends != null && friends.Count > 1)
                            friends = friends.OrderBy(f => f.NikeName).ToList();
                        break;
                    default:
                        if (friends != null && friends.Count > 1)
                            friends = friends.OrderBy(f => f.NikeName).ToList();
                        break;
                }
            }
        }

        private object obj = null;

        public object Obj
        {
            get { return obj; }
            set { obj = value; }
        }

        private bool isExpanded = false;
        /// <summary>
        /// 是否展开
        /// </summary>
        public bool IsExpanded
        {
            get { return isExpanded; }
            set { isExpanded = value; }
        }
    }
}